<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    window.onload = function () {
        var btn = document.getElementById("btn");

        //addEventListener可以为一个元素的相同事件邦定多个响应函数

        // btn.addEventListener("click", function () {
        //     alert("1");
        // }, false);
        // btn.addEventListener("click", function () {
        //     alert("2");
        // }, false);
        // btn.addEventListener("click", function () {
        //     alert("3");
        // }, false);

        function bind(obj,eventStr,callback) {
            if(obj.addEventListener){
                obj.addEventListener(eventStr,callback,false);
            }else{
                obj.attchEvevt("on"+eventStr,callback);
            }
        };
        bind(btn,"click",function () {
            alert(1);
        });
    };
</script>

<body>
    <button id="btn">点我</button>
</body>

</html>